package com.wxg.utils;

import java.io.File;
import java.net.URL;

/**
 * @ClassName MvnProjectUtils
 * @Description TODO
 * @Author Wxg
 * @Date 2018/11/21 14:28
 * @Version 1.0
 */
public class MvnProjectUtils {

    public static File projClassRoot() {
        URL resource = MvnProjectUtils.class.getClassLoader().getResource("");
        return new File(resource.getPath()).getParentFile();
    }

    public static String javaClasspath() {
        File file = projClassRoot();
        File[] files = file.listFiles(pathname -> {
            if (pathname.getName().equals("classes")) {
                return true;
            } else {
                return false;
            }
        });
        return files[0].getPath();
    }

    public static String testClasspath() {
        File file = projClassRoot();
        File[] files = file.listFiles(pathname -> {
            if (pathname.getName().equals("test-classes")) {
                return true;
            } else {
                return false;
            }
        });
        return files[0].getPath();
    }
}
